/**
 * 
 */
package org.pfc.porlapatilla.util;


/**
 * This class provides some internal methods.
 * 
 * @author juan_antonio
 * 
 */
public class Util {
    
//    private static final Map<ImageType, String> extensionMap = new HashMap<ImageType, String>();
//    
//    static {
//	extensionMap.put(ImageType.GIF, ".gif");
//	extensionMap.put(ImageType.JPG, ".jpg");
//	extensionMap.put(ImageType.PNG, ".png");
//    }
//    
//    /**
//     * Returns a String with the image type extension
//     * @param type The image type
//     * @return String which represents image type. If the extension is unknown, returns <code>null</code>
//     */
//    public static String getExtension(ImageType type) {
//	return extensionMap.containsKey(type) ? extensionMap.get(type) : null;
//    }

    /**
     * The detail images path.
     */
    //public static final String IMAGES_PATH = "c:\\images\\detail\\";
//    private static final String IMAGES_PATH = "/Users/jorgepolobermudez/Pictures/detail/";
    private static final String IMAGES_PATH = "/home/pfcmalaga/images/detail/";
    
    /**
     * The thumbnail images path.
     */
//    private static final String THUMBNAILS_PATH = "/Users/jorgepolobermudez/Pictures/thumb/";
    private static final String THUMBNAILS_PATH = "/home/pfcmalaga/images/thumb/";

    /**
     * The thumbnail images width.
     */
    public static final int THUMBNAILS_WIDTH = 50;

    /**
     * The thumbnail images height.
     */
    public static final int THUMBNAILS_HEIGHT = 50;
    
    public static String getBigImagePath(String id) {
	//return IMAGES_PATH + id + getExtension(ImageType.JPG);
	return IMAGES_PATH + id + ".jpg";
    }
    
    public static String getThumbImagePath(String id) {
	//return THUMBNAILS_PATH + id + getExtension(ImageType.JPG);
	return THUMBNAILS_PATH + id + ".jpg";
    }

//    /**
//     * Resize an image.
//     * 
//     * @param imageInByte
//     *            The byte array image.
//     * @param width
//     *            The new image width.
//     * @param height
//     *            The new image height.
//     * @return The resized image.
//     */
//    public static BufferedImage resizeImage(byte[] imageInByte, int width,
//	    int height) {
//	BufferedImage resizedImage = null;
//	BufferedImage bImageFromConvert = null;
//	Graphics2D g;
//	InputStream in = null;
//	int type;
//
//	in = new ByteArrayInputStream(imageInByte);
//	try {
//	    bImageFromConvert = ImageIO.read(in);
//	    type = bImageFromConvert.getType() == 0 ? BufferedImage.TYPE_INT_ARGB
//		    : bImageFromConvert.getType();
//	    resizedImage = new BufferedImage(width, height, type);
//	    g = resizedImage.createGraphics();
//	    g.drawImage(bImageFromConvert, 0, 0, width, height, null);
//	    g.dispose();
//	} catch (IOException e) {
//	    e.printStackTrace();
//	}
//
//	return resizedImage;
//    }
//
//    /**
//     * Store an image in disk.
//     * 
//     * @param path
//     *            The image path.
//     * @param imageInByte
//     *            The image byte array.
//     * @return True if the image have been stored correctly.
//     */
//    public static boolean storeImage(String path, byte[] imageInByte) {
//	InputStream in = new ByteArrayInputStream(imageInByte);
//	BufferedImage bImageFromConvert;
//	try {
//	    bImageFromConvert = ImageIO.read(in);
//	    ImageIO.write(bImageFromConvert, "jpg", new File(path));
//	} catch (IOException e) {
//	    e.printStackTrace();
//	    return false;
//	}
//	return true;
//    }
//
//    /**
//     * Store an image in disk.
//     * 
//     * @param path
//     *            The image path.
//     * @param image
//     *            The image BufferedImage.
//     * @return True if the image have been stored correctly.
//     */
//    public static boolean storeImage(String path, BufferedImage image) {
//	try {
//	    ImageIO.write(image, "jpg", new File(path));
//	} catch (IOException e) {
//	    e.printStackTrace();
//	    return false;
//	}
//	return true;
//    }
//
//    /**
//     * Get an image from disk.
//     * 
//     * @param path
//     *            The image path
//     * @return The stored image.
//     */
//    public static byte[] getImage(String path) {
//	BufferedImage image = null;
//	ByteArrayOutputStream baos = new ByteArrayOutputStream();
//	byte[] imageInByte = null;
//	try {
//	    image = ImageIO.read(new File(path));
//	    ImageIO.write(image, "jpg", baos);
//	    baos.flush();
//	    imageInByte = baos.toByteArray();
//	    baos.close();
//	} catch (IOException e) {
//	    // TODO Auto-generated catch block
//	    e.printStackTrace();
//	}
//	return imageInByte;
//    }

}
